package main

import "fmt"

func main() {
	fmt.Printf("%#v", singleNumber([]int{2, 1, 2, 3, 4, 1}))
}
func singleNumber(nums []int) []int {
	exor := 0
	for _, num := range nums {
		exor ^= num
	}
	exor = exor & -exor
	x, y := 0, 0
	for _, num := range nums {
		if num&exor > 0 {
			x ^= num
		} else {
			y ^= num
		}
	}
	return []int{x, y}
}
